package com.wb.service.impl;

import com.wb.bean.User;
import com.wb.bean.ipdata.IpDataBean;
import com.wb.dao.ipdata.IpDataDao;
import com.wb.service.IPropertiesConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

@Service(value="propertiesConfiguration")
public class PropertiesConfiguration implements IPropertiesConfiguration {

    private final Logger logger = LoggerFactory.getLogger(PropertiesConfiguration.class);

    @Resource(name="user")
    private User user;

    @Resource(name="ipDataDao")
    private IpDataDao ipDataDao;

    @Override
    public User printObject() {
        logger.info("user: {} , ipdata-queyListByParams: {} " , user , ipDataDao.queryCount());
//        return user;
        User user = new User();
        user.setUserName("wangBo");
        user.setAge(22);
        return user;
    }

    @Transactional(rollbackFor= IllegalAccessException.class)
    @Override
    public void insertIpData(IpDataBean ipDataBean) {
        ipDataDao.insertIpData(ipDataBean);
        String a = null;
        a.substring(5);
        ipDataDao.insertIpData(ipDataBean);
    }
}
